package com.zhx.threadcoreknowledge.uncaughtexception;

/**
 * @author ：zhanghaixuan
 * @date ：Created in 2019-10-04 11:19
 * 用途         ： 使用自己写的UNcaughtExceptionHandler 补货异常
 */
public class UseOwnUNcaughtExceptionHandler implements Runnable {

    @Override
    public void run() {
        throw new RuntimeException("报错了");
    }

    public static void main(String[] args) throws InterruptedException {
        Thread.setDefaultUncaughtExceptionHandler(new MyUncaughtExceptionHandler("张海璇"));


        new Thread(new UseOwnUNcaughtExceptionHandler(), "my-thread-1").start();
        Thread.sleep(300);
        new Thread(new UseOwnUNcaughtExceptionHandler(), "my-thread-2").start();
        Thread.sleep(300);
        new Thread(new UseOwnUNcaughtExceptionHandler(), "my-thread-3").start();
        Thread.sleep(300);
        new Thread(new UseOwnUNcaughtExceptionHandler(), "my-thread-4").start();

    }
}
